﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;
using Huirui.Cavan.Domain.MainBoundedContext.SalesModule;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;
using FluentValidation.Attributes;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Employee

    /// <summary>
    /// Employee object for NHibernate mapped table 'Employee'.
    /// </summary>
    [Serializable]
    [Validator(typeof(EmployeeValidator))]
    public class Employee : Persistent<string>
    {
        #region Member Variables

        protected string _name;
        protected Job _job;
        protected decimal? _commissionRate;
        protected SystemIdentifier.Sex _sex;
        protected DateTime? _birthday;
        protected string _email;
        protected string _mobile;
        protected bool _sMSQueryEnabled;
        protected string _remark;
        protected string _managerEmployeeCode;
        protected Corporation _corporation;
        protected Department _department;
        protected UserAccount _userAccount;
        protected IList<Customer> _salesCustomers;
        protected IList<Receivables> _receivableses;
        protected IList<Purchase> _purchases;
        protected IList<PurchaseOrder> _purchaseOrders;
        protected IList<Pay> _pays;
        protected IList<PurchaseReturn> _purchaseReturns;
        protected IList<Sale> _sales;
        protected IList<SalesOrder> _salesOrders;
        protected IList<SalesReturn> _salesReturns;
        protected IList<StockInOut> _stockIns;
        protected IList<StockOutApply> _stockOutApplies;
        protected IList<WareHouse> _wareHouses;

        #endregion

        #region Constructors

        public Employee() { }

        public Employee(string code, string name, Job job, decimal? commissionRate, SystemIdentifier.Sex sex, DateTime? birthday, string email, string mobile, bool sMSQueryEnabled, string remark, string managerEmployeeCode, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation, Department department, UserAccount userAccount)
        {
            this.Id = code;
            this._name = name;
            this._job = job;
            this._userAccount = userAccount;
            this._commissionRate = commissionRate;
            this._sex = sex;
            this._birthday = birthday;
            this._email = email;
            this._mobile = mobile;
            this._sMSQueryEnabled = sMSQueryEnabled;
            this._remark = remark;
            this._managerEmployeeCode = managerEmployeeCode;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._department = department;
        }

        #endregion

        #region Public Properties


        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual Job Job
        {
            get { return _job; }
            set { _job = value; }
        }

        public virtual decimal? CommissionRate
        {
            get { return _commissionRate; }
            set { _commissionRate = value; }
        }

        public virtual SystemIdentifier.Sex Sex
        {
            get { return _sex; }
            set { _sex = value; }
        }

        public virtual DateTime? Birthday
        {
            get { return _birthday; }
            set { _birthday = value; }
        }

        public virtual string Email
        {
            get { return _email; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());
                _email = value;
            }
        }

        public virtual string Mobile
        {
            get { return _mobile; }
            set
            {
                if (value != null && value.Length > 25)
                    throw new ArgumentOutOfRangeException("Invalid value for Mobile", value, value.ToString());
                _mobile = value;
            }
        }

        public virtual bool SMSQueryEnabled
        {
            get { return _sMSQueryEnabled; }
            set { _sMSQueryEnabled = value; }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual string ManagerEmployeeCode
        {
            get { return _managerEmployeeCode; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for ManagerEmployeeCode", value, value.ToString());
                _managerEmployeeCode = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Department Department
        {
            get { return _department; }
            set { _department = value; }
        }

        public virtual UserAccount UserAccount
        {
            get { return _userAccount; }
            set { _userAccount = value; }
        }

        public virtual IList<Customer> Customers
        {
            get
            {
                if (_salesCustomers == null)
                {
                    _salesCustomers = new List<Customer>();
                }
                return _salesCustomers;
            }
            set { _salesCustomers = value; }
        }

        public virtual IList<Receivables> Receivableses
        {
            get
            {
                if (_receivableses == null)
                {
                    _receivableses = new List<Receivables>();
                }
                return _receivableses;
            }
            set { _receivableses = value; }
        }

        public virtual IList<Purchase> Purchases
        {
            get
            {
                if (_purchases == null)
                {
                    _purchases = new List<Purchase>();
                }
                return _purchases;
            }
            set { _purchases = value; }
        }

        public virtual IList<PurchaseOrder> PurchaseOrders
        {
            get
            {
                if (_purchaseOrders == null)
                {
                    _purchaseOrders = new List<PurchaseOrder>();
                }
                return _purchaseOrders;
            }
            set { _purchaseOrders = value; }
        }

        public virtual IList<Pay> Pays
        {
            get
            {
                if (_pays == null)
                {
                    _pays = new List<Pay>();
                }
                return _pays;
            }
            set { _pays = value; }
        }

        public virtual IList<PurchaseReturn> PurchaseReturns
        {
            get
            {
                if (_purchaseReturns == null)
                {
                    _purchaseReturns = new List<PurchaseReturn>();
                }
                return _purchaseReturns;
            }
            set { _purchaseReturns = value; }
        }

        public virtual IList<Sale> Sales
        {
            get
            {
                if (_sales == null)
                {
                    _sales = new List<Sale>();
                }
                return _sales;
            }
            set { _sales = value; }
        }

        public virtual IList<SalesOrder> SalesOrders
        {
            get
            {
                if (_salesOrders == null)
                {
                    _salesOrders = new List<SalesOrder>();
                }
                return _salesOrders;
            }
            set { _salesOrders = value; }
        }

        public virtual IList<SalesReturn> SalesReturns
        {
            get
            {
                if (_salesReturns == null)
                {
                    _salesReturns = new List<SalesReturn>();
                }
                return _salesReturns;
            }
            set { _salesReturns = value; }
        }

        public virtual IList<StockInOut> StockIns
        {
            get
            {
                if (_stockIns == null)
                {
                    _stockIns = new List<StockInOut>();
                }
                return _stockIns;
            }
            set { _stockIns = value; }
        }

        public virtual IList<StockOutApply> StockOutApplies
        {
            get
            {
                if (_stockOutApplies == null)
                {
                    _stockOutApplies = new List<StockOutApply>();
                }
                return _stockOutApplies;
            }
            set { _stockOutApplies = value; }
        }

        public virtual IList<WareHouse> WareHouses
        {
            get
            {
                if (_wareHouses == null)
                {
                    _wareHouses = new List<WareHouse>();
                }
                return _wareHouses;
            }
            set { _wareHouses = value; }
        }



        #endregion
    }
    #endregion
}